<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../head.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>order-list</title>
</head>
<body>

<script type="text/javascript">

	function createOrder() {
        var size = $("input[name=ids]:checked").size();
        if(size == 0){
            alert("请至少选择一个");
            return ;
        }else{
            alert("你确定提交么？");
		}
        $("#jvForm").attr("action","/order/createOrder.do");
        $("#jvForm").attr("method","post").submit();
    }



    $(function(){
        $("#id").blur(function(){
            var id = $("#id").val();
            if(id==""){
                $("#idError").html("订单号不能为空！");
            }else{
                    $.post("/order/createOrderId.do", {id:id},
                        function (data) {
                            if (data == 1) {
                                $("#idError").html("订单号重复!");
                            }else{
                                $("#idError").html("");
							}
                    });
            }
        })
    })
</script>
	<div class="box-positon">
		<div class="rpos">当前位置: 订单管理 - 添加</div>
		<form class="ropt">
			<input type="submit" onclick="this.form.action='/order/list.do';" value="返回列表" class="return-button"/>
		</form>
		<div class="clear"></div>
	</div>
	<div class="body-box">
		<form id="jvForm" >
			<table cellspacing="1" cellpadding="2" border="0" width="100%" class="pn-ftable">
				<tbody>
					<tr>
						<td width="12%" class="pn-flabel pn-flabel-h">订单号:</td>
						<td width="38%" colspan="1" class="pn-fcontent">
							<input type="text" class="required" name="id" id="id" size="40" maxlength="100"/>
							<span style="color: red;" id="idError"></span>
						</td>
						<td width="12%" class="pn-flabel pn-flabel-h">运费:</td>
						<td width="38%" colspan="1" class="pn-fcontent">
							<input type="text" class="required" name="freight"  size="40" maxlength="100"/>
						</td>
					</tr>
					<tr>
						<td width="12%" class="pn-flabel pn-flabel-h">订单金额:</td>
						<td width="38%" colspan="1" class="pn-fcontent">
							<input type="text" class="required" name="orderPrice"  size="40" maxlength="100"/>
						</td>
						<td width="12%" class="pn-flabel pn-flabel-h">应付金额:</td>
						<td width="38%" colspan="1" class="pn-fcontent">
							<input type="text" class="required" name="amountPay"  size="40" maxlength="100"/>
						</td>
					</tr>
					<tr>
						<td width="12%" class="pn-flabel pn-flabel-h">支付方式:</td>
						<td width="38%" colspan="1" class="pn-fcontent">
							<input type="radio" name="paymentWay" value="1" />平台付款
							<input type="radio" name="paymentWay" value="0" />货到付款
						</td>
						<td width="12%" class="pn-flabel pn-flabel-h">支付要求:</td>
						<td width="38%" colspan="1" class="pn-fcontent">
							<input type="radio" name="paymentCash" value="1" />支付宝
							<input type="radio" name="paymentCash" value="0" />现金
						</td>
					</tr>
					<tr>
						<td width="12%" class="pn-flabel pn-flabel-h">支付状态:</td>
						<td width="38%" colspan="1" class="pn-fcontent">
							<input type="radio" name="isPay" value="1" />已付款
							<input type="radio" name="isPay" value="0" />待付款
						</td>
						<td width="12%" class="pn-flabel pn-flabel-h">订单状态:</td>
						<td width="38%" colspan="1" class="pn-fcontent">
							<input type="radio" name="orderState" value="1" />有效订单
							<input type="radio" name="orderState" value="0" />失效订单
						</td>
					</tr>
					<tr>
						<td width="12%" class="pn-flabel pn-flabel-h">用户id:</td>
						<td width="38%" colspan="1" class="pn-fcontent">
							<input type="text" class="required" name="userId"  size="20" maxlength="100"/>
						</td>
						<td width="12%" class="pn-flabel pn-flabel-h">备注:</td>
						<td width="38%" colspan="1" class="pn-fcontent">
							<input type="text" class="required" name="proId" value="" size="50" maxlength="100"/>
						</td>
					</tr>

				</tbody>
				<tbody>
				<tr>
					<td class="pn-fbutton" colspan="2">
						<input type="reset" class="reset" value="重置"/>&nbsp;&nbsp;&nbsp;&nbsp;
						<input type="button" class="submit" onclick="window.location.href='/product/list.do'" value="商品" >
						<%--onclick="window.open('/product/list.do?select=true','','width=800,height=400')"
							点击事件开启新的窗口
						--%>
					</td>
				</tr>
				</tbody>
			</table>
			<div class="body-box">
				<table cellspacing="1" cellpadding="0" border="0" width="100%" class="pn-ltable">
					<thead class="pn-lthead">
					<tr>
						<td><input type="checkbox" onclick="Pn.checkbox('ids',this.checked)"/></td>
						<th>商品id</th>
						<th>商品名称</th>
						<th>商品数量</th>
					</tr>
					</thead>
					<tbody class="pn-ltbody">
					<c:forEach items="${products}" var="pro">
						<tr bgcolor="#ffffff" onmouseover="this.bgColor='#eeeeee'" onmouseout="this.bgColor='#ffffff'">
							<td><input type="checkbox" name="ids" value="${pro.id}"/></td>
							<td align="center">${pro.id}</td>
							<td align="center"><input type="text"  name="names" size="150" maxlength="150" value="${pro.name}" ></td>
							<td align="center"><input type="text" name="pno" size="5"></td>
						</tr>
					</c:forEach>
					</tbody>
				</table>
				<td class="pn-fbutton" colspan="2">
					<input type="button" class="submit" value="提交" onclick="createOrder()"/>
				</td>
			</div>
		</form>
	</div>
</body>
</html>